/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * pnl_ClassesList.java
 *
 * Created on Aug 7, 2009, 2:34:33 PM
 */

package jia.editor.lists;

import jia.editor.EditorMain;
import jia.editor.widgets.RacesTable;
import jia.tools.PanelSwapper;

/**
 *
 * @author estell
 */
public class pnl_ClassesList extends javax.swing.JPanel {
    private RacesTable races;
    /** Creates new form pnl_ClassesList */
    public pnl_ClassesList() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        sp_Classes = new javax.swing.JSplitPane();
        scrl_ClassesTable = new javax.swing.JScrollPane();
        scrl_Details = new javax.swing.JScrollPane();
        tp_Details = new javax.swing.JTextPane();
        btn_Add = new javax.swing.JButton();
        btn_Edit = new javax.swing.JButton();
        btn_Delete = new javax.swing.JButton();
        btn_Cancel = new javax.swing.JButton();

        setMinimumSize(new java.awt.Dimension(800, 580));
        setPreferredSize(new java.awt.Dimension(800, 580));

        sp_Classes.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Classes", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.BELOW_TOP));
        sp_Classes.setDividerLocation(400);
        sp_Classes.setDividerSize(7);
        sp_Classes.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
        sp_Classes.setOneTouchExpandable(true);
        sp_Classes.setPreferredSize(new java.awt.Dimension(642, 558));
        sp_Classes.setLeftComponent(scrl_ClassesTable);

        tp_Details.setBackground(new java.awt.Color(0, 0, 0));
        tp_Details.setForeground(new java.awt.Color(255, 255, 255));
        scrl_Details.setViewportView(tp_Details);

        sp_Classes.setRightComponent(scrl_Details);

        btn_Add.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jia_ui/images/add.png"))); // NOI18N
        btn_Add.setText("Add");
        btn_Add.setPreferredSize(new java.awt.Dimension(132, 30));
        btn_Add.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_AddActionPerformed(evt);
            }
        });

        btn_Edit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jia_ui/images/pencil.png"))); // NOI18N
        btn_Edit.setText("Edit");
        btn_Edit.setPreferredSize(new java.awt.Dimension(132, 30));
        btn_Edit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_EditActionPerformed(evt);
            }
        });

        btn_Delete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jia_ui/images/delete.png"))); // NOI18N
        btn_Delete.setText("Delete");
        btn_Delete.setPreferredSize(new java.awt.Dimension(132, 30));

        btn_Cancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jia_ui/images/door_out.png"))); // NOI18N
        btn_Cancel.setText("Cancel");
        btn_Cancel.setPreferredSize(new java.awt.Dimension(132, 30));
        btn_Cancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_CancelActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 800, Short.MAX_VALUE)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .add(sp_Classes, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(btn_Add, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(btn_Edit, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(btn_Delete, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(btn_Cancel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 580, Short.MAX_VALUE)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(sp_Classes, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(layout.createSequentialGroup()
                        .add(btn_Add, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(btn_Edit, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(btn_Delete, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 426, Short.MAX_VALUE)
                        .add(btn_Cancel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        sp_Classes.getAccessibleContext().setAccessibleName("Classes");
    }// </editor-fold>//GEN-END:initComponents

    private void btn_AddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_AddActionPerformed
//        PanelSwapper.swap(new RacesForm(), this);
//        try {
//            if (this.getParent() != null){
//                this.getParent().remove(this);
//            }
//            this.finalize();
//        } catch (Throwable ex) {
//            ex.printStackTrace();
//        }
}//GEN-LAST:event_btn_AddActionPerformed

    private void btn_EditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_EditActionPerformed
//        Race thisRace = (Race)races.dataList.get(races.getSelectedRow());
//        System.out.println(thisRace.getRaceName() + " was selected for edit");
//        PanelSwapper.swap(new RacesForm(String.valueOf(thisRace.getRaceId())), this);
//        try {
//            if (this.getParent() != null){
//                this.getParent().remove(this);
//            }
//            this.finalize();
//        } catch (Throwable ex) {
//            ex.printStackTrace();
//        }
}//GEN-LAST:event_btn_EditActionPerformed

    private void btn_CancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_CancelActionPerformed
        PanelSwapper.swap(EditorMain.p_defaultAdminPanel, this);
        try {
            if (this.getParent() != null){
                this.getParent().remove(this);
            }
            this.finalize();
        } catch (Throwable ex) {
            ex.printStackTrace();
        }
}//GEN-LAST:event_btn_CancelActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btn_Add;
    private javax.swing.JButton btn_Cancel;
    private javax.swing.JButton btn_Delete;
    private javax.swing.JButton btn_Edit;
    private javax.swing.JScrollPane scrl_ClassesTable;
    private javax.swing.JScrollPane scrl_Details;
    private javax.swing.JSplitPane sp_Classes;
    private javax.swing.JTextPane tp_Details;
    // End of variables declaration//GEN-END:variables

}
